home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-PPC / DELAY.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  841b  |  34 lines

  1. #ifndef _PPC_DELAY_H
  2. #define _PPC_DELAY_H
  3.  
  4. /*
  5.  * Copyright 1996, Paul Mackerras.
  6.  *
  7.  * This program is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU General Public License
  9.  * as published by the Free Software Foundation; either version
  10.  * 2 of the License, or (at your option) any later version.
  11.  */
  12.  
  13. extern unsigned long loops_per_sec;
  14.  
  15. extern __inline__ void __delay(unsigned int loops)
  16. {
  17.     if (loops != 0)
  18.         __asm__ __volatile__("mtctr %0; 1: bdnz 1b" : :
  19.                      "r" (loops) : "ctr");
  20. }
  21.  
  22. extern __inline__ void udelay(unsigned long usecs)
  23. {
  24.     unsigned long loops;
  25.  
  26.     /* compute (usecs * 2^32 / 10^6) * loops_per_sec / 2^32 */
  27.     usecs *= 0x10c6;        /* 2^32 / 10^6 */
  28.     __asm__("mulhwu %0,%1,%2" : "=r" (loops) :
  29.         "r" (usecs), "r" (loops_per_sec));
  30.     __delay(loops);
  31. }
  32.  
  33. #endif /* defined(_PPC_DELAY_H) */
  34.